home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / WINDOW.DMO < prev    next >
Text File  |  1988-12-18  |  4KB  |  188 lines

  1. #include <jaz.h>
  2. #include <keys.h>
  3. #include <jzscreen.h>
  4. #include <gscreen.h>
  5.  
  6. char *wtext1[] = {
  7. "Welcome to the JazSoft \"C\" Library",
  8. "This demo illustrates the use of some",
  9. "of the screen and window routines.",
  10. "If you are interested in obtaining",
  11. "Source code and the libraries to over",
  12. "125 functions, Contact:",
  13. "JazSoft Software (Jack A. Zucker)",
  14. "301-794-5950  301-794-8763  CIS:75766,1336",
  15. "Press any key to continue...",
  16. ""
  17. };
  18.  
  19. char *wtext2[] = {
  20. "The first example shows how to overlay",
  21. "a window with another one. The first window",
  22. "is still there. It's just hiding underneath",
  23. "the second one!",
  24. "Here, I'll show you...",
  25. ""
  26. };
  27.  
  28. char *wtext3[] = {
  29. "The second example shows",
  30. "how to move a window to",
  31. "another part of the screen",
  32. "Use the arrow keys and then",
  33. "Press <Enter> when done.",
  34. ""
  35. };
  36.  
  37. char *wtext4[] = {
  38. "We can even change",
  39. "the color of the window.",
  40. "It's as easy as:",
  41. ""
  42. };
  43.  
  44. char *wnum[] = {
  45. "ONE...",
  46. "TWO...",
  47. "THREE...",
  48. ""
  49. };
  50.  
  51. main()
  52. {
  53.   TWINDOW *wptr[10];        /* pointer to window structure */
  54.   TWINDOW *originalscreen;
  55.   int w,wrow,wcol;
  56.   int wch,wscan;
  57.  
  58.   originalscreen = jzappend(&g_header,0,0,0,25,80,0xff);
  59.  
  60.   #if ! DEBUG
  61.     jzlogo();
  62.   #endif
  63.  
  64.   jzclswnd(0xff);
  65.  
  66.   wptr[0] = jzopnwnd(0,5,25,45,11,WHITE,BLUE);
  67.  
  68.   showtext(wtext1);
  69.  
  70.   wptr[1] = jzcpywnd(wptr[0],1);
  71.  
  72.   getch();
  73.  
  74.   wptr[2] = jzopnwnd(2,10,32,45,7,BLACK,RED);
  75.  
  76.   showtext(wtext2);
  77.  
  78.   wptr[3] = jzcpywnd(wptr[2],3);
  79.  
  80.   for (w = 0 ; w < 5 ; w ++) {
  81.     if (w & 1) jzrstwnd(wptr[1]);
  82.     else jzrstwnd(wptr[3]);
  83.     jzdelay(18L);
  84.   }
  85.  
  86.   wptr[4] = jzopnwnd(4,12,40,30,7,BLUE,CYAN);
  87.  
  88.   showtext(wtext3);
  89.  
  90.   wptr[5] = jzcpywnd(wptr[4],5);
  91.  
  92.   wcol = 40;                 /* init column */
  93.   wrow = 12;                 /* init row    */
  94.  
  95.   do {
  96.     if (wch = jzinkey(&wscan)) {     /* not a special char */
  97.       if (wch == 13) break;         /* exit loop on enter key */
  98.     }
  99.     else
  100.       switch (wscan) {
  101.     case UARR : if (wrow > 0) {
  102.               wrow --;
  103.               jzrstwnd(wptr[4]);  /* restore previous window */
  104.               wptr[4]->row1--;
  105.               wptr[4]->row2--;
  106.               jzsavwnd(wptr[4]);
  107.               jzmovwnd(wptr[5],wrow,wcol);
  108.             }
  109.             break;
  110.     case DARR : if (wrow < 17) {
  111.               wrow ++;
  112.               jzrstwnd(wptr[4]);  /* restore previous window */
  113.               wptr[4]->row1++;
  114.               wptr[4]->row2++;
  115.               jzsavwnd(wptr[4]);
  116.               jzmovwnd(wptr[5],wrow,wcol);
  117.             }
  118.             break;
  119.     case LARR : if (wcol > 0) {
  120.               wcol --;
  121.               jzrstwnd(wptr[4]);  /* restore previous window */
  122.               wptr[4]->col1--;
  123.               wptr[4]->col2--;
  124.               jzsavwnd(wptr[4]);
  125.               jzmovwnd(wptr[5],wrow,wcol);
  126.              }
  127.             break;
  128.     case RARR : if (wcol < 50) {
  129.               wcol ++;
  130.               jzrstwnd(wptr[4]);  /* restore previous window */
  131.               wptr[4]->col1++;
  132.               wptr[4]->col2++;
  133.               jzsavwnd(wptr[4]);
  134.               jzmovwnd(wptr[5],wrow,wcol);
  135.             }
  136.             break;
  137.       }
  138.   } while (-1);
  139.  
  140.   wptr[6] = jzopnwnd(6,0,0,26,8,BLACK,MAGENTA);
  141.  
  142.   showtext(wtext4);
  143.  
  144.   wptr[7] = jzcpywnd(wptr[6],7);
  145.  
  146.  
  147.   for (w = 0; *wnum[w] ; w ++) {
  148.     locate(w+3,0);
  149.     wprintf(wnum[w]);
  150.     jzclrwnd(wptr[7],(w << 5) + 1);
  151.     jzdelay(18L);
  152.   }
  153.  
  154.   for (w = 6 ; w >= 0 ; w -= 2) {
  155.     jzdelay(18L);
  156.     jzclswnd(w);
  157.   }
  158.  
  159.   jzloccur(23,0);
  160.  
  161. }
  162.  
  163. showtext(fstr)
  164. char **fstr;
  165. {
  166.   int w;
  167.  
  168.   for (w = 0 ; *fstr[w] ; w ++) {
  169.     locate(w,0);
  170.     clickwrite(fstr[w]);
  171.   }
  172. }
  173.  
  174. clickwrite(fstr)
  175. char *fstr;
  176. {
  177.  
  178.   while (*fstr) {
  179.     wprintf("%c",*fstr++);
  180.     #if ! DEBUG
  181.       soundon(20000);
  182.       jzdelay(1L);
  183.       soundoff();
  184.     #endif
  185.   }
  186. }
  187.  
  188.